<div class="popup_body">
    <div class="ui_table">
        <form method="post">
            <input type="hidden" name="id" value="${entity.id}">
            <input type="hidden" name="packId"value="${entity.packId}">
            <table cellpadding="0" cellspacing="0">
                <tr>
                    <td width="80" align="right">电池组序号：</td>
                    <td><input type="text" required="required" class="text easyui-validatebox" name="packNo" readonly id="pack_no_${pid}" value="${(entity.packNo)!''}"/></td>
                </tr>
                <tr>
                    <td width="80" align="right">外壳编号：</td>
                    <td><input type="text" required="required" class="text easyui-validatebox" name="shellCode"  id="shell_code_${pid}" value="${(entity.shellCode)!''}"/></td>
                </tr>
                <tr>
                <#--新增：运营商代理商栏目-->
                <#--如果是总部登录    <#if !entity.supplierId??||entity.supplierId==0>-->
                    <#if Session['SESSION_KEY_USER'].type == Session['USER_TYPE_PLATFORM'].value>
                        <td align="right">运营商：</td>
                        <td>
                            <input name="agentId" class="easyui-combotree" editable="false"
                                           style="width: 184px; height: 28px;" value="${(batteryAgent.agentId)!''}"
                                           data-options="url:'${contextPath}/security/basic/agent/tree.htm?',method:'get',onSelect: function(rec){
                                           var url = '${contextPath}/security/hdw/agency/tree.htm?agentId='+rec.id;
                                           $('#agency_id_${pid}').combotree('reload', url);},
                                           onChange:function(){
                                            $('#agency_id_${pid}').combotree('clear');
                                            }
                                            "/>
                        </td>
                         <#--如果是代理商登录 就隐藏-->
                         <#elseif Session['SESSION_KEY_USER'].type == Session['USER_TYPE_AGENCY'].value||Session['SESSION_KEY_USER'].type == Session['USER_TYPE_AGENT'].value>
                         <#--隐藏-->
                            <input type="hidden" name="agentId" value="${Session['SESSION_KEY_USER'].agentId}">
                    </#if>
                </tr>
                    <#--如果是总部或者运营商登录-->
                    <#if Session['SESSION_KEY_USER'].type == Session['USER_TYPE_PLATFORM'].value||Session['SESSION_KEY_USER'].type == Session['USER_TYPE_AGENT'].value>
                        <td align="right">代理商：</td>
                        <td>
                            <input name="agencyId" class="easyui-combotree" editable="false"
                                   style="width: 184px; height: 28px;" id="agency_id_${pid}" value="${(batteryAgent.agencyId)!''}"
                                   data-options="<#if Session['SESSION_KEY_USER'].agentId??&&Session['SESSION_KEY_USER'].agentId!=0>url:'${contextPath}/security/hdw/agency/tree.htm?agentId=${Session['SESSION_KEY_USER'].agentId}',</#if>method:'get'"
                            />
                        </td>
                    <#--如果是代理商登录就 隐藏-->
                    <#elseif Session['SESSION_KEY_USER'].type == Session['USER_TYPE_AGENCY'].value>
                        <input type="hidden" name="agencyId" value="${Session['SESSION_KEY_USER'].agencyId}">
                    </#if>


            </table>
        </form>
    </div>
</div>
<div class="popup_btn">
    <button class="btn btn_red ok">确定</button>
    <button class="btn btn_border close">关闭</button>
</div>
<script>
    $(function () {
        var pid = '${pid}',
                win = $('#' + pid),
                form = win.find('form');

        win.find('button.ok').click(function () {
            form.form('submit', {
                url: '${contextPath}/security/hdw/battery/updateAgent.htm',
                success: function (text) {
                    var json = $.evalJSON(text);
                <@app.json_jump/>
                    if (json.success) {
                        $.messager.alert('提示信息', '操作成功', 'info');
                        win.window('close');
                    } else {
                        $.messager.alert('提示信息', json.message, 'info');
                    }
                }
            });
        });
        win.find('button.close').click(function () {
            win.window('close');
        });
        $('#pack_no_${pid}').click(function() {
            App.dialog.show({
                css: 'width:600px;height:620px;',
                title: '选择电池组',
                href: "${contextPath}/security/hdw/battery_pack/select_battery_pack.htm",
                windowData: {
                    ok: function(param) {
                        win.find('input[name=packId]').val(param.id);
                        win.find('input[name=packNo]').val(param.packNo);
                    }
                }
            });
        });

    })
</script>
